// 拼接HTTPUrl
function getUrl(type, pathname) {
  return window.RPConfig[type] + pathname
}

const coverApi = {
  // 获取用户业务单元
  getUserBu: param => {
    return $http.get(getUrl('itShare', '/fillingCenter/getUserBu'), param).then(res => res.data)
  },
  // 获取覆盖度目标所有数据
  getGoalData: params => {
    return $http.post(getUrl('itShare', '/dc/target/page'), params).then(res => res.data)
  },
  // 获取覆盖度目标单条数据
  getGoalById: params => {
    return $http.post(getUrl('itShare', '/dc/target/getById'), params)
  },
  // 覆盖度目标获取新建表格
  getCreateGoalData: params => {
    return $http.post(getUrl('itShare', `/dc/target/getEmptyTable`), params)
  },

  // 覆盖度目标新增数据
  createGoalData: params => {
    return $http.post(getUrl('itShare', `/dc/target/insert`), params)
  },

  // 获取覆盖度现状所有数据
  getStatusData: params => {
    return $http.post(getUrl('itShare', '/dc/current/page'), params).then(res => res.data)
  },
  // 获取覆盖度现状单条数据
  getStatusById: params => {
    return $http.post(getUrl('itShare', '/dc/current/getById'), params)
  },
  // 覆盖度现状获取新建表格
  getCreateStatusData: params => {
    return $http.post(getUrl('itShare', `/dc/current/getEmptyTable`), params)
  },
  // 覆盖度现状新增数据
  createStatusData: params => {
    return $http.post(getUrl('itShare', '/dc/current/insert'), params)
  },
  // 修改数据
  updateData: params => {
    return $http.post(getUrl('itShare', '/dcBuData/update'), params).then(res => res.data)
  },
  // 覆盖度分页查询所有数据
  commonPage: params => {
    return $http.post(getUrl('itShare', '/dc/common/page'), params).then(res => res.data)
  },
  // 覆盖度现状上季度数据
  getLastStatusData: params => {
    return $http.get(
      getUrl('itShare', `/dc/current/getPreviousData?buCode=${params.buCode}&dcPeriod=${params.dcPeriod}`)
    )
  },
  // 查看时目标获取单条数据
  getCoverPageGoalById: params => {
    return $http.post(getUrl('itShare', '/dc/target/view/getById'), params).then(res => res.data)
  },
  // 查看时现状获取单条数据
  getCoverPageStatusById: params => {
    return $http.post(getUrl('itShare', '/dc/current/view/getById'), params).then(res => res.data)
  },
  // 获取关联系统
  getConnectSys: params => {
    return $http.post(getUrl('itShare', '/dc/target/sys/page'), params).then(res => res.data)
  },
  // 获取流程跟踪图Url
  getProcessUrl: param => {
    return $http.get(getUrl('itShare', '/dc/common/getProcessDiagramUrl'), param).then(res => res.data)
  },
  // 获取流程详情Url
  getProcessDetail: param => {
    return $http.get(getUrl('itShare', '/dc/common/getUrlNoHost'), param).then(res => res.data)
  },
  // 获取流程审批记录
  getProcessComment: param => {
    return $http.get(getUrl('itShare', `/dc/common/getProcessComment?processInstId=${param}`)).then(res => res.data)
  },
  // 复活流程
  reactivateProcess: param => {
    return $http.get(getUrl('itShare', '/dc/common/reactivateProcess'), param).then(res => res.data)
  },
  // 获取流程详情URL
  getUrlHost: processInstId => {
    return $http.get(getUrl('itShare', `/dc/common/getUrlNoHost?processInstId=${processInstId}`)).then(res => res.data)
  },
  // 关键业务环节数字化覆盖情况
  summaryOverall: param => {
    return $http.get(getUrl('itShare', `/dc/common/summary/overall`), param).then(res => res.data)
  },
  // 数字化覆盖度走势
  trend: param => {
    return $http.get(getUrl('itShare', `/dc/common/summary/trend`), param).then(res => res.data)
  },
  // 集团关键业务环节数字化覆盖度汇总表
  summary: param => {
    return $http.get(getUrl('itShare', `/dc/common/summary`), param).then(res => res.data)
  },
  // 数字化覆盖度季度提升情况
  improvement: param => {
    return $http.get(getUrl('itShare', `/dc/common/summary/improvement`), param).then(res => res.data)
  },
  // 获取业务单元列表接口(包含集团总部和华润集团)
  getBuList: params => {
    return $http.get(getUrl('itShare', `/fillingCenter/trgNode/list/all?areaCode=dc`), params)
  },
  // 覆盖度上传附件修改数据
  updateFile: params => {
    return $http.post(getUrl('itShare', `/dcTemplateConfig/update`), params)
  },
  // 覆盖度上传附件
  getFileById: params => {
    return $http.get(getUrl('itShare', `/dcTemplateConfig/getById`), params)
  },
  // 覆盖度现状计算覆盖度
  currentCompute: params => {
    return $http.post(
      getUrl('itShare', `/dc/current/compute?buCode=${params.buCode}&dcPeriod=${params.dcPeriod}`),
      params
    )
  },
  // 删除表单数据
  removeForm: params => {
    return $http.post(
      getUrl('itShare', `/dc/common/delete`),
      params
    )
  }
}

export default coverApi
